package com.blensmile.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Blensmile on 2016/1/5.
 */
public class StreamUtils {

    public static String Stream2String(InputStream stream) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = 0;
        while (-1 != (len = stream.read(buffer))) {
            bos.write(buffer, 0, len);
        }
        String str = bos.toString("utf-8");
        bos.close();
        stream.close();
        return str;
    }

}
